package com.ids.redis;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by sagnitude on 12/30/2015.
 */
public class RedisConn {

    private static RedisConn instance;

    private Set<HostAndPort> jedisClusterNodes;
    private JedisCluster jedisCluster;

    private RedisConn() {
        if (jedisClusterNodes == null) {
            jedisClusterNodes = new HashSet<>();
            jedisClusterNodes.add(new HostAndPort("192.168.1.201", 7401));
            jedisCluster = new JedisCluster(jedisClusterNodes);
        }
    }

    public static RedisConn getInstance() {
        if (instance == null) {
            instance = new RedisConn();
        }
        return instance;
    }

    public JedisCluster getCluster() {
        return jedisCluster;
    }
}
